﻿Public Class frmTest

    Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

    Private Sub frmTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load



    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        'TextBox1.Text = String.Empty
        'For Index As Integer = 1 To 255
        '    TextBox1.AppendText(Index.ToString + ":" + GetAsyncKeyState(Index).ToString + "   ")
        'Next

    End Sub

    Private Sub frmTest_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown

        Dim strString As String = "cuốn sách"
        Dim strTarget As String = String.Empty
        TextBox1.Text = ""
        For Index As Integer = 65000 To 100000
            strTarget = "Error"
            Try
                Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding(Index)
                strTarget = enc.GetString(enc.GetBytes(strString))
                If strTarget = strString Then
                    TextBox1.AppendText(Format(Index, "0000000") + vbTab + strTarget + vbCrLf)
                    Application.DoEvents()
                End If

            Catch ex As Exception

            End Try

            Me.Text = Index
            '
        Next

    End Sub
End Class